package com.fary.config;

import com.fary.config.property.CompositePropertySourceFactory;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.util.List;

@Data
@ConfigurationProperties("mq")
@Configuration
@PropertySource(value = "classpath:ibm-mq.yml", factory = CompositePropertySourceFactory.class)
public class MQConfigProperties {

    private String user;

    private String password;

    private String isEncrypt;

    private String encryptKey;

    private String waitInterval;

    private Receiver receiver;

    private Sender sender;

    @Data
    public static class Receiver {

        private String errorWaitMills;

        private String exceptionWaitMills;

        private List<Source> sourceList;
    }

    @Data
    public static class Sender {
        /**
         * 主机
         */
        private String host;
        /**
         * 端口
         */
        private int port;

        /**
         * ccsid
         */
        private int ccsId;

        /**
         * 队列管理器
         */
        private String manager;
        /**
         * 异常重发次数
         */
        private Integer reSendCount = 3;
        /**
         * 异常重连时间间隔
         */
        private Long reConnectInterval = 2000L;

        /**
         * 异常重连时间间隔
         */
        private Long timeOut = (long) 0;
        /**
         * 节点list
         */
        private List<Dest> destList;
    }

    @Data
    public static class Source {

        private String nodeFlag;

        private String host;

        private int port;

        private int ccsId;

        private String manager;

        private String channel;

        private String queue;

        private String errQueue;
    }

    @Data
    public static class Dest {
        /**
         * 系统代码
         */
        private String sysCode;

        /**
         * 服务端连接通道
         */
        private String channel;

        /**
         * 业务队列
         */
        private String queueName;

        /**
         * 业务主题
         */
        private String topic;
    }

}
